import { defineStore } from "pinia";
import { Names } from "../../store-namespace";
import { _get, _post, _put, _delete, http } from "@/utils/axios";
import { AssetElectric } from "@/api/backend/index";

export const useAssetElectric = defineStore(Names.AssetElectric, {
  state: () => {
    return {
      single: <any>{},
      type: <any>[], //电表类型
      typeOnline: <any>[], //电表在线状态
      typeSwitch: <any>[], //电表开关类型
      typeLabel: <any>[], //电表用能类型
      sites: <any>{}, //站点map
      tags: <any>{},
      editsiteName: "", //编辑表单待查站点名称
      ecode:""//待查电表号
    };
  },
  getters: {},
  actions: {
    //获取电表列表数据
    getList(filter: any) {
      return new Promise((resolve, reject) => {
        _get(AssetElectric + "/list", filter, "json", "")
          .then((res: any) => {
            console.log("获取电表列表数据", res);
            resolve(res);
          })
          .catch((err: any) => {
            console.log(err);
            reject(err);
          });
      });
    },
  },
});
